<#include "../common/_header.htm">
<div id="hidebox" style="height:100%;width:100%">
    <div class="box-body table-responsive">
        <div style="display: flex;flex-direction: row-reverse;">
            <input type="button" class="btn btn-primary daobtn" onclick="exportDetailList();" value="导出" />
        </div>
        <table id="table" class="table text-nowrap"></table>
    </div>
</div>
<script>
    var dialog = top.dialog.get(window);
    var data = dialog.data; // 获取对话框传递过来的数据
    $(function() {
        /** 回去传值 **/
        $('#table').datagrid({
            url: '${ctx}/bszjzy/detail',
            method: 'post',
            iconCls: 'icon-save',
            queryParams:data,
            pageSize:30,
            pageList:[30,50,100,150,200],
            pageNumber:1,//当前页号,
            loadMsg:"正在加载，请稍后",//加载数据时的提示信息
            emptyMsg:"暂无信息",//加载数据为空时的信息
            height:($(window).height())-50,
            rownumbers:true,//序号
            fitColumns: true,//使表格自适应页面宽度
            //pagination: true,//是否分页
            singleSelect: true,
            columns:[[ //每一列的具体设置。
                {field:'ACCOUNT_BODY',title:'交易主体'},
                {field:'ACCOUNT_BODY_NUMBER',title:'交易主体账号'},
                {field:'ACCOUNT_BODY_CARD',title:'交易主体卡号'},
                {field:'ACCOUNT_RIVAL',title:'交易对手'},
                {field:'ACCOUNT_RIVAL_NUMBER',title:'交易对手账号'},
                {field:'ACCOUNT_RIVAL_CARD',title:'交易对手卡号'},
                {field:'SIGN',title:'交易类型',
                    formatter: function(value,row,index){ //当前值，当前的row，当前的索引
                        return value==0?'流入':'流出'
                    }
                },
                {field:'TRADE_DATE',title:'交易时间',sortable: true,
                    formatter: function(value,row,index){ //当前值，当前的row，当前的索引
                        if(value){
                            var date = new Date(value);
                            return formatDate(date, 'yyyy-MM-dd hh:mm:ss');
                        }else{
                            return '-';
                        }
                    }
                },
                {field:'ACCOUNT_MONEY',title:'交易金额',sortable: true},
                {field:'SURPLUS_MONEY',title:'交易后余额',sortable: true},
                {field:'CONTENT_ABSTRACT',title:'摘要'},
                {field:'ACCOUNT_RIVAL_BANK',title:'对手归属行'},
                {field:'ACCOUNT_BODY_BANK',title:'主体归属行'},
                {field:'INSTITUTION_NUMBER',title:'对方机构号'},
                {field:'TELLER_NUMBER',title:'柜员号'},
                {field:'REMARKS',title:'备注'}
            ]],
            onHeaderContextMenu: function(e, field){
                e.preventDefault();
                if (!cmenu){
                    createColumnMenu();
                }
                cmenu.menu('show', {
                    left:e.pageX,
                    top:e.pageY
                });
            }
        })
    });
    function exportDetailList(){
        let starTime = data.beginDate;
        let endTime = data.endDate;
        let sign=data.sign;
        let caseId=data.casemanageId;
        let accountRivalCard=data.accountRivalCard;
        let accountRivalCard2=data.accountRivalCard2;
        let arr = parent.parent._checkedAccount;
        if (arr&&arr.length>1){
            toastr.error("请选择一个交易主体卡号","提示信息");
            return false;
        }
        let accountBodyCard=arr[0].split("_")[1];;

        var xhr = new XMLHttpRequest();
        var url="${ctx}/bszjzy/downDetailExcel";
        xhr.open('POST', url, true);
        xhr.responseType = "blob";  // 返回类型blob
        // 定义请求完成的处理函数
        xhr.onload = function () {
            // 请求完成
            if (this.status === 200) {
                var content = this.response;
                var aTag = document.createElement('a');
                var blob = new Blob([content]);
                var headerName = xhr.getResponseHeader("Content-disposition");
                var fileName = decodeURIComponent(headerName).substring(20);
                aTag.download = fileName;
                aTag.href = URL.createObjectURL(blob);
                aTag.click();
                URL.revokeObjectURL(blob);
            }
        };
        // 发送ajax请求
        var formdata=new FormData();
        formdata.append("casemanageId",caseId);
        formdata.append("sign",sign);
        formdata.append("accountRivalCard",accountRivalCard);
        formdata.append("accountBodyCard",accountBodyCard);
        formdata.append("beginDate",starTime);
        formdata.append("endDate",endTime);
        formdata.append("accountRivalCard2",accountRivalCard2);
        xhr.send(formdata);
    };
</script>
<style>
    #hidebox {
        top: 23px;
        left: 2%;
        border-radius: 5px;
        background-color:#fff;
        z-Index:9999;
        padding: 10px;
        overflow:hidden;
    }
    .box-body.table-responsive {
        height: 100%;
    }
</style>
</body>
</html>
